import { 
  Entity, 
  PrimaryGeneratedColumn, 
  Column, 
  CreateDateColumn, 
  UpdateDateColumn,
  DeleteDateColumn,
  Index 
} from 'typeorm';

@Entity({ 
  name: 'ya_system_user',
  engine: 'InnoDB',
  comment: '用户管理'
})
export class SystemUser {
  @PrimaryGeneratedColumn({
    type: 'int',
    name: 'user_id',
    comment: '用户id'
  })
  userId: number;

  @Column({
    type: 'int',
    name: 'avatar_id',
    default: 0,
    comment: '头像id'
  })
  avatarId: number;

  @Column({
    type: 'varchar',
    length: 64,
    default: '',
    comment: '编号'
  })
  number: string;

  @Column({
    type: 'varchar',
    length: 64,
    nullable: false,
    comment: '用户昵称'
  })
  nickname: string;

  @Column({
    type: 'varchar',
    length: 64,
    nullable: false,
    comment: '用户账号'
  })
  username: string;

  @Column({
    type: 'varchar',
    length: 255,
    nullable: false,
    comment: '密码'
  })
  password: string;

  @Column({
    type: 'varchar',
    length: 12,
    default: '',
    comment: '手机'
  })
  phone: string;

  @Column({
    type: 'varchar',
    length: 255,
    default: '',
    comment: '邮箱'
  })
  email: string;

  @Column({
    type: 'varchar',
    length: 255,
    default: '',
    comment: '备注'
  })
  remark: string;

  @Column({
    type: 'int',
    default: 250,
    comment: '排序'
  })
  sort: number;

  @Column({
    type: 'tinyint',
    width: 1,
    default: 0,
    comment: '是否超管，1是0否'
  })
  isSuper: number;

  @Column({
    type: 'tinyint',
    width: 1,
    default: 0,
    comment: '是否禁用，1是0否'
  })
  isDisable: number;

  @Column({
    type: 'tinyint',
    width: 1,
    default: 0,
    comment: '是否删除，1是0否'
  })
  isDelete: number;

  @Column({
    type: 'int',
    default: 0,
    comment: '登录次数'
  })
  loginNum: number;

  @Column({
    type: 'varchar',
    length: 20,
    default: '',
    comment: '登录IP'
  })
  loginIp: string;

  @Column({
    type: 'varchar',
    length: 255,
    default: '',
    comment: '登录地区'
  })
  loginRegion: string;

  @Column({
    type: 'datetime',
    nullable: true,
    comment: '登录时间'
  })
  loginTime: Date;

  @Column({
    type: 'datetime',
    nullable: true,
    comment: '退出时间'
  })
  logoutTime: Date;

  @Column({
    type: 'datetime',
    nullable: true,
    comment: '密码修改时间'
  })
  pwdTime: Date;

  @Column({
    type: 'int',
    name: 'create_uid',
    default: 0,
    comment: '添加用户id'
  })
  createUid: number;

  @Column({
    type: 'int',
    name: 'update_uid',
    default: 0,
    comment: '修改用户id'
  })
  updateUid: number;

  @Column({
    type: 'int',
    name: 'delete_uid',
    default: 0,
    comment: '删除用户id'
  })
  deleteUid: number;

  @CreateDateColumn({
    name: 'create_time',
    comment: '添加时间'
  })
  createTime: Date;

  @UpdateDateColumn({
    name: 'update_time',
    comment: '修改时间'
  })
  updateTime: Date;

  @DeleteDateColumn({
    name: 'delete_time',
    nullable: true,
    comment: '删除时间'
  })
  deleteTime: Date;
}